<?php

/**
* IndexController.class.php UTF-8
* @date: 2016年3月30日上午11:44:20
* @license 这不是一个自由软件，未经授权不许任何使用和传播。
* @author: wuyonghong <wyh@1tsdk.com>
* @version: 1.0
* 
*/
namespace Front\Controller;
use Common\Controller\AgentPublicController;
class IndexController extends AgentPublicController {
    
    function _initialize(){        
        parent::_initialize();
    }
    
    /* 首页  */
    public function index(){
        if($this->is_subagent_site()){
            redirect(U('Front/Account/login'));
            exit;
        }
        
		$model=M('tui_news');
        $news=$model->order("id desc")->limit(4)->select();
        $this->assign("news",$news);
        
        
        $game_model=M('tui_games');
        $hot_games=$game_model
                ->field("g.name,g.icon,g.id")
                ->alias("tg")
                ->join("LEFT JOIN ".C('DB_PREFIX')."game g ON g.id=tg.game_id")
                ->where(array("tag"=>"hot"))
                ->limit(4)
                ->select();
        $about_online_games=$game_model
                ->field("g.name,g.icon,g.id")
                ->alias("tg")
                ->join("LEFT JOIN ".C('DB_PREFIX')."game g ON g.id=tg.game_id")
                ->where(array("tag"=>"about_online"))
                ->limit(4)
                ->select();
        
        
        $this->assign("hot_games",$hot_games);
        $this->assign("about_online_games",$about_online_games);
    	$this->display();
    }
    
    
}